import {
	IMEditViewAbility,
	IMEditViewController,
	IMEditViewStore,
	IMultiEditViewPanelAbility,
	IParam,
	IViewActionResult,
	MEditViewActionType,
} from '@/core/interface';
import { MDViewController } from './md-view-controller';

/**
 * 多表单编辑视图控制器
 *
 * @export
 * @class MEditViewController
 * @extends {MDViewController<MEditViewActionType, IMEditViewStore, IMEditViewAbility>}
 * @implements {IMEditViewController<IMEditViewStore, IMEditViewAbility>}
 */
export class MEditViewController
	extends MDViewController<
		MEditViewActionType,
		IMEditViewStore,
		IMEditViewAbility
	>
	implements IMEditViewController<IMEditViewStore, IMEditViewAbility>
{
	/**
	 * 获取多编辑视图面板能力
	 *
	 * @protected
	 * @return {*}  {(IMultiEditViewPanelAbility | undefined)}
	 * @memberof MEditViewController
	 */
	protected getMDCtrlAbility(): IMultiEditViewPanelAbility | undefined {
		const meditViewPanel = this.model.ctrls.find(
			(ctrl: IParam) => ctrl.controlType === 'MULTIEDITVIEWPANEL'
		);
		if (meditViewPanel) {
			return this.getSubAbility<IMultiEditViewPanelAbility>(
				meditViewPanel.name
			);
		}
		return undefined;
	}
}
